<template>
  <div>
    <myheader></myheader>
    <navtable></navtable>
    <b class="line"></b>
    <div class="clear"></div>
    <div class="center" style="margin-top:0px">
      <div class="col-main">
        <div class="main-wrap">

          <div class="user-comment">
            <!--标题 -->
            <div class="am-cf am-padding">
              <div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">评价管理</strong> / <small>Manage&nbsp;Comment</small></div>
            </div>
            <hr />

            <div class="am-tabs am-tabs-d2 am-margin" data-am-tabs>
              <div class="am-tabs-bd">
                <div class="am-tab-panel am-fade am-in am-active" id="tab1" v-if="flag">

                  <div class="comment-main">
                    <div class="comment-list">
                      <el-table :data="comments" border style="width: 100%">
                        <el-table-column label="商品" width="180">
                          <template slot-scope="scope">
                            <img v-bind:src="scope.row.itemImg" width="80px">
                          </template>
                        </el-table-column>
                        <el-table-column prop="buyerComment" label="评价" width="180">
                        </el-table-column>
                        <el-table-column prop="mchtName" label="卖家">
                        </el-table-column>
                        <el-table-column label="时间">
                          <template slot-scope="scope">
                            <p v-text="dateFormatter(scope.row.createTime)"></p>
                          </template>
                        </el-table-column>
                        <el-table-column prop="address" label="操作">
                          <template slot-scope="scope">
                            <el-button type="text" @click="delComment(scope.row.id)"> 删除 </el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                  </div>
                  <div class="block fr mt-30 mb-30" style="float:right">
                    <el-pagination background @current-change="qryComments" :current-page.sync="index" :page-size="pageSize" layout="prev, pager, next" :total="total">
                    </el-pagination>
                  </div>
                </div>

              </div>
            </div>

          </div>

        </div>
        <!--底部-->
        <foot></foot>
      </div>
      <leftmenu></leftmenu>
    </div>
    <navfull></navfull>
  </div>
</template>

<script>
import myheader from '@/components/myheader.vue'
import navfull from '@/components/navfull.vue'
import navtable from '@/components/navtable.vue'
import leftmenu from '@/components/leftmenu.vue'
import foot from '@/components/foot.vue'
export default {
  name: 'comments',
  data () {
    return {
      index: 1,
      total: 10,
      pageSize: 10,
      comments: [],
      orders: [],
      flag: true
    }
  },
  components: {
    myheader,
    navfull,
    navtable,
    leftmenu,
    foot
  },
  mounted () {
    this.qryComments();
  },
  methods: {
    qryComments () {
      this.axios.get("/trade/comments4P", {
        params: {
          buyerId: -1,
          type: 1,
          index: this.index,
          pageSize: this.pageSize
        }
      }).then((res) => {
        var result = res.data;
        if (result.code == 200) {
          this.comments = result.data;
           this.total = result.total;
        }
      })
    },
    delComment (id) {
      this.axios.delete("/trade/comment", {
        params: {
          id: id
        }
      }).then((res) => {
        let result = res.data;
        if (result.code == 200) {
          this.$layer.msg("删除成功");
          this.qryComments();
        }
      })
    },
    dateFormatter (date) {
      var time = new Date(date);
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
    },
  }
}
function add0 (m) {
  return m < 10 ? '0' + m : m
}
</script>

<style scoped>
@import "../../../AmazeUI-2.4.2/assets/css/admin.css";
@import "../../../AmazeUI-2.4.2/assets/css/amazeui.css";
@import "../../../assets/css/personal.css";
@import "../../../assets/css/cmstyle.css";
</style>
